.class public Lcom/estrongs/dlna/core/b;
.super Ljava/lang/Object;
.source "DlnaEngineManager.java"


# static fields
.field private static h:Lcom/estrongs/dlna/core/b;


# instance fields
.field private final a:Les/f10;

.field private final b:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List<",
            "Lcom/estrongs/dlna/core/c;",
            ">;"
        }
    .end annotation
.end field

.field private final c:Landroid/content/ServiceConnection;

.field private d:Landroid/content/Context;

.field private e:Lorg/teleal/cling/android/AndroidUpnpService;

.field private f:I

.field private g:Lorg/teleal/cling/registry/Registry;


# direct methods
.method private constructor <init>()V
    .locals 1

    .line 1
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    const/4 v0, -0x1

    .line 2
    iput v0, p0, Lcom/estrongs/dlna/core/b;->f:I

    .line 3
    new-instance v0, Les/f10;

    invoke-direct {v0}, Les/f10;-><init>()V

    iput-object v0, p0, Lcom/estrongs/dlna/core/b;->a:Les/f10;

    .line 4
    new-instance v0, Ljava/util/concurrent/CopyOnWriteArrayList;

    invoke-direct {v0}, Ljava/util/concurrent/CopyOnWriteArrayList;-><init>()V

    iput-object v0, p0, Lcom/estrongs/dlna/core/b;->b:Ljava/util/List;

    .line 5
    new-instance v0, Lcom/estrongs/dlna/core/b$a;

    invoke-direct {v0, p0}, Lcom/estrongs/dlna/core/b$a;-><init>(Lcom/estrongs/dlna/core/b;)V

    iput-object v0, p0, Lcom/estrongs/dlna/core/b;->c:Landroid/content/ServiceConnection;

    return-void
.end method

.method static synthetic a(Lcom/estrongs/dlna/core/b;I)I
    .locals 0

    .line 2
    iput p1, p0, Lcom/estrongs/dlna/core/b;->f:I

    return p1
.end method

.method static synthetic a(Lcom/estrongs/dlna/core/b;)Ljava/util/List;
    .locals 0

    .line 3
    iget-object p0, p0, Lcom/estrongs/dlna/core/b;->b:Ljava/util/List;

    return-object p0
.end method

.method static synthetic a(Lcom/estrongs/dlna/core/b;Lorg/teleal/cling/android/AndroidUpnpService;)Lorg/teleal/cling/android/AndroidUpnpService;
    .locals 0

    .line 1
    iput-object p1, p0, Lcom/estrongs/dlna/core/b;->e:Lorg/teleal/cling/android/AndroidUpnpService;

    return-object p1
.end method

.method static synthetic b(Lcom/estrongs/dlna/core/b;)V
    .locals 0

    .line 1
    invoke-direct {p0}, Lcom/estrongs/dlna/core/b;->h()V

    return-void
.end method

.method public static g()Lcom/estrongs/dlna/core/b;
    .locals 2

    .line 1
    sget-object v0, Lcom/estrongs/dlna/core/b;->h:Lcom/estrongs/dlna/core/b;

    if-nez v0, :cond_1

    .line 2
    const-class v0, Lcom/estrongs/dlna/core/b;

    monitor-enter v0

    .line 3
    :try_start_0
    sget-object v1, Lcom/estrongs/dlna/core/b;->h:Lcom/estrongs/dlna/core/b;

    if-nez v1, :cond_0

    .line 4
    new-instance v1, Lcom/estrongs/dlna/core/b;

    invoke-direct {v1}, Lcom/estrongs/dlna/core/b;-><init>()V

    sput-object v1, Lcom/estrongs/dlna/core/b;->h:Lcom/estrongs/dlna/core/b;

    .line 5
    :cond_0
    monitor-exit v0

    goto :goto_0

    :catchall_0
    move-exception v1

    monitor-exit v0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v1

    .line 6
    :cond_1
    :goto_0
    sget-object v0, Lcom/estrongs/dlna/core/b;->h:Lcom/estrongs/dlna/core/b;

    return-object v0
.end method

.method private h()V
    .locals 2

    .line 1
    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->e:Lorg/teleal/cling/android/AndroidUpnpService;

    invoke-interface {v0}, Lorg/teleal/cling/android/AndroidUpnpService;->getRegistry()Lorg/teleal/cling/registry/Registry;

    move-result-object v0

    iput-object v0, p0, Lcom/estrongs/dlna/core/b;->g:Lorg/teleal/cling/registry/Registry;

    .line 2
    iget-object v1, p0, Lcom/estrongs/dlna/core/b;->a:Les/f10;

    invoke-interface {v0, v1}, Lorg/teleal/cling/registry/Registry;->addListener(Lorg/teleal/cling/registry/RegistryListener;)V

    .line 3
    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->a:Les/f10;

    iget-object v1, p0, Lcom/estrongs/dlna/core/b;->g:Lorg/teleal/cling/registry/Registry;

    invoke-interface {v1}, Lorg/teleal/cling/registry/Registry;->getRemoteDevices()Ljava/util/Collection;

    move-result-object v1

    invoke-virtual {v0, v1}, Les/f10;->a(Ljava/util/Collection;)V

    const/4 v0, 0x0

    .line 4
    invoke-virtual {p0, v0}, Lcom/estrongs/dlna/core/b;->a(Z)V

    return-void
.end method


# virtual methods
.method public a()Lorg/teleal/cling/android/AndroidUpnpService;
    .locals 1

    .line 8
    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->e:Lorg/teleal/cling/android/AndroidUpnpService;

    return-object v0
.end method

.method public a(Ljava/lang/String;)Lorg/teleal/cling/model/meta/Device;
    .locals 2

    if-eqz p1, :cond_1

    .line 20
    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->g:Lorg/teleal/cling/registry/Registry;

    if-nez v0, :cond_0

    goto :goto_0

    .line 21
    :cond_0
    invoke-static {p1}, Lorg/teleal/cling/model/types/UDN;->valueOf(Ljava/lang/String;)Lorg/teleal/cling/model/types/UDN;

    move-result-object p1

    const/4 v1, 0x1

    invoke-interface {v0, p1, v1}, Lorg/teleal/cling/registry/Registry;->getDevice(Lorg/teleal/cling/model/types/UDN;Z)Lorg/teleal/cling/model/meta/Device;

    move-result-object p1

    return-object p1

    :cond_1
    :goto_0
    const/4 p1, 0x0

    return-object p1
.end method

.method public a(Landroid/content/Context;)V
    .locals 2

    .line 4
    iget v0, p0, Lcom/estrongs/dlna/core/b;->f:I

    const/4 v1, -0x1

    if-eq v0, v1, :cond_0

    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->d:Landroid/content/Context;

    if-nez v0, :cond_1

    :cond_0
    const/4 v0, 0x0

    .line 5
    iput v0, p0, Lcom/estrongs/dlna/core/b;->f:I

    .line 6
    invoke-virtual {p1}, Landroid/content/Context;->getApplicationContext()Landroid/content/Context;

    move-result-object p1

    iput-object p1, p0, Lcom/estrongs/dlna/core/b;->d:Landroid/content/Context;

    const/4 v0, 0x1

    .line 7
    invoke-static {p1, v0}, Les/n10;->a(Landroid/content/Context;Z)V

    :cond_1
    return-void
.end method

.method public a(Lcom/estrongs/dlna/core/c;)V
    .locals 1

    .line 10
    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->b:Ljava/util/List;

    invoke-interface {v0, p1}, Ljava/util/List;->contains(Ljava/lang/Object;)Z

    move-result v0

    if-nez v0, :cond_0

    .line 11
    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->b:Ljava/util/List;

    invoke-interface {v0, p1}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    :cond_0
    return-void
.end method

.method public a(Les/e10;)V
    .locals 1

    .line 9
    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->a:Les/f10;

    invoke-virtual {v0, p1}, Les/f10;->a(Les/e10;)V

    return-void
.end method

.method public a(Les/l10;)V
    .locals 1

    .line 18
    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->a:Les/f10;

    if-eqz v0, :cond_0

    .line 19
    invoke-virtual {v0, p1}, Les/f10;->a(Les/l10;)V

    :cond_0
    return-void
.end method

.method public a(Lorg/teleal/cling/controlpoint/ActionCallback;)V
    .locals 1

    .line 16
    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->e:Lorg/teleal/cling/android/AndroidUpnpService;

    if-eqz v0, :cond_0

    .line 17
    invoke-interface {v0}, Lorg/teleal/cling/android/AndroidUpnpService;->getControlPoint()Lorg/teleal/cling/controlpoint/ControlPoint;

    move-result-object v0

    invoke-interface {v0, p1}, Lorg/teleal/cling/controlpoint/ControlPoint;->execute(Lorg/teleal/cling/controlpoint/ActionCallback;)V

    :cond_0
    return-void
.end method

.method public a(Z)V
    .locals 1

    if-eqz p1, :cond_0

    .line 12
    iget-object p1, p0, Lcom/estrongs/dlna/core/b;->e:Lorg/teleal/cling/android/AndroidUpnpService;

    if-eqz p1, :cond_0

    .line 13
    invoke-interface {p1}, Lorg/teleal/cling/android/AndroidUpnpService;->getRegistry()Lorg/teleal/cling/registry/Registry;

    move-result-object p1

    invoke-interface {p1}, Lorg/teleal/cling/registry/Registry;->removeAllRemoteDevices()V

    .line 14
    :cond_0
    iget-object p1, p0, Lcom/estrongs/dlna/core/b;->e:Lorg/teleal/cling/android/AndroidUpnpService;

    if-eqz p1, :cond_1

    invoke-static {}, Les/n10;->e()Z

    move-result p1

    if-eqz p1, :cond_1

    .line 15
    iget-object p1, p0, Lcom/estrongs/dlna/core/b;->e:Lorg/teleal/cling/android/AndroidUpnpService;

    invoke-interface {p1}, Lorg/teleal/cling/android/AndroidUpnpService;->getControlPoint()Lorg/teleal/cling/controlpoint/ControlPoint;

    move-result-object p1

    const/4 v0, 0x2

    invoke-interface {p1, v0}, Lorg/teleal/cling/controlpoint/ControlPoint;->search(I)V

    :cond_1
    return-void
.end method

.method public b()Ljava/util/List;
    .locals 1
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/List<",
            "Les/l10;",
            ">;"
        }
    .end annotation

    .line 3
    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->a:Les/f10;

    invoke-virtual {v0}, Les/f10;->a()Ljava/util/List;

    move-result-object v0

    return-object v0
.end method

.method public b(Les/e10;)V
    .locals 1

    .line 2
    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->a:Les/f10;

    invoke-virtual {v0, p1}, Les/f10;->b(Les/e10;)V

    return-void
.end method

.method public c()Ljava/lang/String;
    .locals 1

    .line 1
    invoke-static {}, Les/n10;->a()Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public d()Ljava/lang/String;
    .locals 2

    .line 1
    :try_start_0
    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->e:Lorg/teleal/cling/android/AndroidUpnpService;

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->e:Lorg/teleal/cling/android/AndroidUpnpService;

    invoke-interface {v0}, Lorg/teleal/cling/android/AndroidUpnpService;->get()Lorg/teleal/cling/UpnpService;

    move-result-object v0

    if-eqz v0, :cond_0

    .line 2
    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->e:Lorg/teleal/cling/android/AndroidUpnpService;

    invoke-interface {v0}, Lorg/teleal/cling/android/AndroidUpnpService;->get()Lorg/teleal/cling/UpnpService;

    move-result-object v0

    invoke-interface {v0}, Lorg/teleal/cling/UpnpService;->getConfiguration()Lorg/teleal/cling/UpnpServiceConfiguration;

    move-result-object v0

    invoke-interface {v0}, Lorg/teleal/cling/UpnpServiceConfiguration;->createNetworkAddressFactory()Lorg/teleal/cling/transport/spi/NetworkAddressFactory;

    move-result-object v0

    invoke-interface {v0}, Lorg/teleal/cling/transport/spi/NetworkAddressFactory;->getBindAddresses()[Ljava/net/InetAddress;

    move-result-object v0

    const/4 v1, 0x0

    aget-object v0, v0, v1

    .line 3
    invoke-virtual {v0}, Ljava/net/InetAddress;->getHostAddress()Ljava/lang/String;

    move-result-object v0
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    return-object v0

    :catch_0
    move-exception v0

    .line 4
    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V

    .line 5
    :cond_0
    invoke-static {}, Les/n10;->b()Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public e()V
    .locals 1

    const/4 v0, 0x1

    .line 1
    invoke-virtual {p0, v0}, Lcom/estrongs/dlna/core/b;->a(Z)V

    return-void
.end method

.method public declared-synchronized f()V
    .locals 4

    monitor-enter p0

    :try_start_0
    const-string v0, "DLNA : startEngine"

    .line 1
    invoke-static {v0}, Les/m10;->b(Ljava/lang/String;)V

    .line 2
    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->d:Landroid/content/Context;

    if-eqz v0, :cond_3

    iget v0, p0, Lcom/estrongs/dlna/core/b;->f:I

    const/4 v1, -0x1

    if-eq v0, v1, :cond_3

    .line 3
    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->e:Lorg/teleal/cling/android/AndroidUpnpService;

    if-eqz v0, :cond_1

    iget v0, p0, Lcom/estrongs/dlna/core/b;->f:I

    const/4 v1, 0x2

    if-eq v0, v1, :cond_0

    goto :goto_1

    .line 4
    :cond_0
    iget v0, p0, Lcom/estrongs/dlna/core/b;->f:I

    if-ne v0, v1, :cond_2

    .line 5
    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->b:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v0

    :goto_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v1

    if-eqz v1, :cond_2

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/estrongs/dlna/core/c;

    .line 6
    invoke-virtual {v1}, Lcom/estrongs/dlna/core/c;->a()V

    goto :goto_0

    :cond_1
    :goto_1
    const/4 v0, 0x1

    .line 7
    iput v0, p0, Lcom/estrongs/dlna/core/b;->f:I

    .line 8
    new-instance v1, Landroid/content/Intent;

    iget-object v2, p0, Lcom/estrongs/dlna/core/b;->d:Landroid/content/Context;

    const-class v3, Lcom/estrongs/dlna/core/DlnaUpnpService;

    invoke-direct {v1, v2, v3}, Landroid/content/Intent;-><init>(Landroid/content/Context;Ljava/lang/Class;)V

    .line 9
    iget-object v2, p0, Lcom/estrongs/dlna/core/b;->d:Landroid/content/Context;

    iget-object v3, p0, Lcom/estrongs/dlna/core/b;->c:Landroid/content/ServiceConnection;

    invoke-virtual {v2, v1, v3, v0}, Landroid/content/Context;->bindService(Landroid/content/Intent;Landroid/content/ServiceConnection;I)Z

    .line 10
    iget-object v0, p0, Lcom/estrongs/dlna/core/b;->d:Landroid/content/Context;

    invoke-static {v0}, Lcom/estrongs/dlna/core/f;->a(Landroid/content/Context;)Lcom/estrongs/dlna/core/f;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 11
    :cond_2
    monitor-exit p0

    return-void

    .line 12
    :cond_3
    :try_start_1
    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string v1, "please init first!!"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    :catchall_0
    move-exception v0

    monitor-exit p0

    goto :goto_3

    :goto_2
    throw v0

    :goto_3
    goto :goto_2
.end method
